cssanimatedstyle: Avoid type check in loop
authorTimm Bäder <mail@baedert.org>
Mon, 19 Aug 2019 06:46:27 +0000 (08:46 +0200)
committerTimm Bäder <mail@baedert.org>
Mon, 9 Sep 2019 15:36:23 +0000 (17:36 +0200)
We can just do the check once as source is not going to change within
the loop.

gtk/gtkcssanimatedstyle.c

index 21cc98c4fc234ec52df921229fec145681d03828..eb930c4a863cfd92639e73cdc339e496b8aaecb5 100644 (file)
@@ -270,6 +270,7 @@ gtk_css_animated_style_create_css_transitions (GSList              *animations,
 {
   TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
   GtkCssValue *durations, *delays, *timing_functions;
+  gboolean source_is_animated;
   guint i;
 
   durations = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DURATION);
@@ -284,6 +285,7 @@ gtk_css_animated_style_create_css_transitions (GSList              *animations,
 
   transition_infos_set (transitions, gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));
 
+  source_is_animated = GTK_IS_CSS_ANIMATED_STYLE (source);
   for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
     {
       GtkStyleAnimation *animation;
@@ -298,14 +300,14 @@ gtk_css_animated_style_create_css_transitions (GSList              *animations,
       if (duration + delay == 0.0)
         continue;
 
-      if (GTK_IS_CSS_ANIMATED_STYLE (source))
+      if (source_is_animated)
         {
-          start = gtk_css_animated_style_get_intrinsic_value (GTK_CSS_ANIMATED_STYLE (source), i);
+          start = gtk_css_animated_style_get_intrinsic_value ((GtkCssAnimatedStyle *)source, i);
           end = gtk_css_style_get_value (base_style, i);
 
           if (_gtk_css_value_equal (start, end))
             {
-              animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
+              animation = gtk_css_animated_style_find_transition ((GtkCssAnimatedStyle *)source, i);
               if (animation)
                 {
                   animation = _gtk_style_animation_advance (animation, timestamp);